package com.programming.common.action;

import com.opensymphony.xwork2.ActionSupport;
import com.programming.common.Constants;
import com.programming.common.page.Page;
import com.programming.common.page.SplitPageBean;
import com.programming.movie.service.ManagerService;

public abstract class BaseAction extends ActionSupport {
	private int pageSize = 10;
	private int currnetPageNo = 1;
	public ManagerService managerService;

	/**
	 * @return the managerService
	 */
	public ManagerService getManagerService() {
		return managerService;
	}

	/**
	 * @param managerService
	 *            the managerService to set
	 */
	public void setManagerService(ManagerService managerService) {
		this.managerService = managerService;
	}

	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * @param pageSize
	 *            the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * @return the currnetPageNo
	 */
	public int getCurrnetPageNo() {
		return currnetPageNo;
	}

	/**
	 * @param currnetPageNo
	 *            the currnetPageNo to set
	 */
	public void setCurrnetPageNo(int currnetPageNo) {
		this.currnetPageNo = currnetPageNo;
	}

	/**
	 * 
	 */
	private static final long serialVersionUID = 1768975689726097684L;

	public SplitPageBean convert(Page page, String url, String param) {
		return new SplitPageBean(page.getStart(), page.getPageSize(), page.getCurrentPageNo(), page.getTotalCount(), page.getResult(), url, param);
	}

	public SplitPageBean convert(Page page, String url) {
		return this.convert(page, url, Constants.SPLIT_PAGE_CURRENTPAGENO_PARAM);
	}

	public SplitPageBean convert(Page page) {
		return this.convert(page, "", Constants.SPLIT_PAGE_CURRENTPAGENO_PARAM);
	}
}
